import wx, string, os
import wx.adv
from wx.adv import Wizard as wiz
from wx.adv import WizardPage, WizardPageSimple
from wx.lib import scrolledpanel
import wx.lib.buttons as buttons

from JDjango.constant import *
from JDjango.api import view_type_data
from JDjango.dialogs.MessageDialog.RichMessageDialog import RichMsgDialog
from JDjango.api import environment as env
from JDjango.api import djangotools
from JDjango.api import retools

from ..PythonEditor import *



def makePageTitle(wizPg, title):
    '''设置页面标题（即将弃用）'''
    sizer = wx.BoxSizer(wx.VERTICAL)
    wizPg.SetSizer(sizer) # 向导 Page 页面绑定垂直布局
    title = wx.StaticText(wizPg, -1, title)
    title.SetFont(wx.Font(18, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD))
    sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    sizer.Add(wx.StaticLine(wizPg, -1), 0, wx.EXPAND|wx.ALL, 5)
    return sizer

class TitledPage(wx.adv.WizardPageSimple):
    '''简单信息页'''
    def __init__(self, parent, title):
        WizardPageSimple.__init__(self, parent)
        self.sizer = makePageTitle(self, title)

class SkipNextPage(wx.adv.WizardPage):
    '''复杂功能页
    
        必须实现 GetNext() 和 GetPrev() 方法
        理应实现 GetBitmap() 方法
    '''
    def __init__(self, parent, title):
        WizardPage.__init__(self, parent)
        self.next = self.prev = None
        self.sizer = makePageTitle(self, title)

        self.checkBox = wx.CheckBox(self, -1, '跳过下一页')
        self.sizer.Add(self.checkBox, 0, wx.ALL, 5)

    def SetNext(self, next):
        '''设置后一页'''
        self.next = next

    def SetPrev(self, prev):
        '''设置前一页'''
        self.prev = prev

    def GetNext(self):
        '''获取下一页/下一指定页'''
        if self.checkBox.GetValue():
            self.next.GetNext().SetPrev(self)
            return self.next.GetNext() # 直接跳往下下页
        else:
            self.next.GetNext().SetPrev(self.next)
            return self.next

    def GetPrev(self):
        '''获取上一页/上一指定页'''
        return self.prev

    # def GetBitmap(self): '''设置图标'''

class UseAltBitmapPage(WizardPage):
    '''使用特殊的位图页'''
    def __init__(self, parent, title):
        WizardPage.__init__(self, parent)
        self.next = self.prev = None
        self.sizer = makePageTitle(self, title)

        self.sizer.Add(wx.StaticText(self, -1, '本页使用了不一样的位图'), 0, wx.ALL, 5)

    def SetNext(self, next):
        self.next = next

    def SetPrev(self, prev):
        self.prev = prev

    def GetNext(self):
        return self.next

    def GetPrev(self):
        return self.prev

    # def GetBitmap(self): '''设置图标'''
